#include "stdafx.h"
#include "WindowMetrics.h"
#include "TextMetrics.h"
#include "Text.h"

void WindowMetrics::UseNumArea(bool use)
{
	if(use)
	{
		numAreaWidth = tm->GetFontWidthAverage() * ((text->GetNumberOfRows() > 10000)? 6 : 4)
			+ tm->GetFontWidthAverage() / 3;
	}
	else
	{
		numAreaWidth = 0;
	}
	SetMarginWidth();
}

void WindowMetrics::UseMarkArea(bool use)
{
	markAreaWidth = (use)? tm->GetFontWidthAverage() * 2 : 0;
	SetMarginWidth();
}

int WindowMetrics::GetWndWidth()
{
	return wndWidth;
}

int WindowMetrics::GetWndHeight()
{
	return wndHeight;
}

int WindowMetrics::GetFormattingWidth()
{
	return wndWidth - marginWidth - 4;
}

int WindowMetrics::GetMarginWidth()
{
	return marginWidth;
}

int WindowMetrics::GetMarkAreaWidth()
{
	return markAreaWidth;
}

int WindowMetrics::GetNumAreaWidth()
{
	return numAreaWidth;
}

bool WindowMetrics::IsMarkArea()
{
	return markAreaWidth != 0;
}

bool WindowMetrics::IsNumArea()
{
	return numAreaWidth != 0;
}

RECT WindowMetrics::GetFormattingRect()
{
	RECT rect = {marginWidth, 0, wndWidth, wndHeight};
	return rect;
}

void WindowMetrics::SetMarginWidth()
{
	marginWidth = markAreaWidth + numAreaWidth + 10;
}

void WindowMetrics::SetData(int width, int height)
{
	wndWidth = width;
	wndHeight = height;
}

void WindowMetrics::Init(TextMetrics* tm, Text* text)
{
	this->tm = tm;
	this->text = text;
}